package com.sptpc.learnspring.controller.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 假设下游只有一个调饮师服务可处理支付订单
 * 采用Direct策略
 */
@Configuration
public class DrinkBrewConfig {
    public static final String EXCHANGE_NAME = "drink-brew";

    @Bean
    DirectExchange directExchange() {
        return new DirectExchange(EXCHANGE_NAME, true, false);
    }

    @Bean
    Queue queue() {
        return new Queue("paid-order");
    }

    @Bean
    Binding binding() {
        return BindingBuilder.bind(queue())
                .to(directExchange())
                .with("paid-order");
    }
}
